package com.copyctrl.admin.controller;

import com.copyctrl.admin.dto.DynamicDTO;
import com.copyctrl.admin.service.DynamicService;
import com.copyctrl.campus.common.model.ApiResponse;
import com.copyctrl.feignapi.client.DynamicClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author:JH
 * @version:1.0
 */
@RestController
@RequestMapping("/dynamic")
public class DynamicController {
    @Autowired
    DynamicService service;
    @Autowired
    DynamicClient dynamicClient;

    @GetMapping
    public ApiResponse findAll(){
        List<DynamicDTO> all = service.findAll();
        return ApiResponse.ofSuccess(all);
    }

    @DeleteMapping("/{id}")
    public ApiResponse delete(@PathVariable Integer id){
       return  dynamicClient.deleteDynamic(id);
    }

}
